package com.adhere.system.mapper;

import com.adhere.system.pojo.RbacPrivilege;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * rbac_privilege表行数据执行“逻辑真删除” Mapper 接口
 * </p>
 *
 * @author 
 * @since 2021-04-02
 */
public interface RbacPrivilegeMapper extends BaseMapper<RbacPrivilege> {

    @Select("select a.* from rbac_privilege a left join rbac_role_privilege b on a.code = b.privilege_code where b.role_code = #{roleCode}")
    List<RbacPrivilege> getPrivilegeListByRoleCode(String roleCode);

    List<RbacPrivilege> getPrivilegeByRoleList(List<String> roleCodeList);

    @Select("SELECT a.* FROM rbac_privilege a LEFT JOIN rbac_role_privilege b ON a.code = b.privilege_code LEFT JOIN rbac_user_role c ON b.role_code = c.role_code WHERE c.user_code = #{userCode} group by a.id")
    List<RbacPrivilege> getPrivilegeListByUserCode(String userCode);
}
